package org.sepheriel.airy2d;

import org.sepheriel.airy2d.entity.Player;
import org.sepheriel.airy2d.game.EngineInterface;
import org.sepheriel.airy2d.physic.PMath;
import org.sepheriel.airy2d.screen.Camera;
import org.sepheriel.airy2d.screen.Image;
import org.sepheriel.airy2d.shader.Blur;
import org.sepheriel.airy2d.shader.Shock;
import org.sepheriel.airy2d.tiles.TileWorld;

class AiryTest implements EngineInterface {
	
	private Engine engine;
	private int delta = 0;
	
	static String title = "Peter";
	
	Image playerTex;
	TileWorld myWorld;
	Blur post;
	Shock shock;
	Camera cam;
	Player player;
	PMath pmath;
	

	AiryTest(String title)
	{
		engine = Engine.getInstance();
		engine.connectInterface(this);
	}

	@Override
	public void update(int _delta) {
		delta = _delta;
		engine.setTitle(title+engine.getFps());
		engine.updateFPS();
	}

	@Override
	public void render() {
		//test.draw(100, 0);
		myWorld.render(cam);
		player.drawCenter(cam);
	}
	
	public static void main(String[] args) {
		AiryTest airy = new AiryTest(title);
		airy.engine.start();
	}

	@Override
	public void init() {
		playerTex = new Image("res/char.png");
		myWorld = new TileWorld(2, 64);
		cam = new Camera();
		post = new Blur(engine.getResolution());
		player = new Player(playerTex);
		pmath = new PMath(delta);
		shock = new Shock(engine.getResolution());
	}

	@Override
	public void postFX() {
		post.draw(engine.getFramebufferID(), delta);
		shock.draw(engine.getFramebufferID(), delta);

	}
}